package com.ocr.OcrImage;

import com.ocr.Utils.ImgUtils;
import com.ocr.OtherDemo.Tess4J;

import java.io.File;

/**
 * Created by chenyuncong on 2019/6/26.
 */
public class OcrCtrl {
    public static void main(String[] args) throws Exception {

//        "D:\\data\\orc\\q"+i+".png","D:\\data\\orc\\q_file\\q"+i+".png"
        //原始验证码地址
        String OriginalImg = "C:\\mysoftware\\images\\upload\\OcrImg\\oi.jpg";
        //识别样本输出地址
        String ocrResult = "C:\\mysoftware\\images\\upload\\OcrResult\\or.jpg";
        for (int i = 0; i < 16; i++) {
            OriginalImg = "D:\\data\\orc\\q" + i + ".png";
            ocrResult = "D:\\data\\orc\\tess4j\\q" + i + ".png";
            System.out.println(ocrResult);
            //去噪点
            ImgUtils.removeBackground(OriginalImg, ocrResult);
            //裁剪边角
            ImgUtils.cuttingImg(ocrResult);
            //OCR识别
            String code = new OCRHelper().recognizeText(new File(ocrResult));
//            String code = Tess4J.executeTess4J(ocrResult);
            //输出识别结果
            System.out.println("Ocr识别结果: \n" + code);
        }

    }
}
